<template>
  <div class="form">
    <div class="form-item">
      <div class="label">科目：</div>
      <div class="input">
        <input type="text" placeholder="请输入科目" v-model.trim="subject" />
      </div>
    </div>
    <div class="form-item">
      <div class="label">分数：</div>
      <div class="input">
        <input type="text" placeholder="请输入分数" v-model.number="score" />
      </div>
    </div>
    <div class="form-item">
      <div class="label"></div>
      <div class="input">
        <button class="submit" @click.prevent="AddFn">添加</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  // 零时存放
  data(){
    return{
      subject : '',
      score : ''
    }
  },
  methods:{
    // 添加，吧数据子传父
    AddFn(){
      this.$emit('addStu', this.subject, this.score)
      // 恢复初始
      this.subject = '',
      this.score = ''
    }
  }
}
</script>

<style></style>
